package com.dragon.app.concurrent;

import java.util.concurrent.CountDownLatch;

/**
 * 
 * <p>class: CountDownLatchTest</p>  
 * <p>Description: 测试并发倒计时计数器</p>  
 * @author SmallDragon
 * @date 2019年5月6日
 *
 */
public class CountDownLatchTest {

	public static void main(String[] args) {
		CountDownLatch countDownLatch = new CountDownLatch(6);

		for (int i = 0; i < 6; i++) {
			new Thread(() -> {
				System.out.println(Thread.currentThread().getName() + "\t上完自习，离开教室。。。");
				countDownLatch.countDown();
			}, String.valueOf(i)).start();
		}

		try {
			countDownLatch.await();
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println(Thread.currentThread().getName() + "\t班长锁门，离开教室。。。");

	}

}
